package client;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.UnknownHostException;

/**
 * Created with IntelliJ IDEA.
 * User: Igor Demidov
 * Date: 24.02.13
 * Time: 11:25
 */
public class BeginGUI {
    private JButton registerButton;
    private JPanel panel1;
    private JButton loginButton;
    private JButton aboutButton;
    private JLabel info;
    private JFrame frame;

    public BeginGUI(final MainClient client) throws UnknownHostException {
        frame = new JFrame("Start page");
        frame.setContentPane(this.panel1);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
        aboutButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //AboutPageGUI aboutPageGUI = new AboutPageGUI();
                JOptionPane.showMessageDialog(frame, "<html>Mail Project<br>Igor Demidov<br>2013</html>", "Info", JOptionPane.INFORMATION_MESSAGE);
            }
        });
        registerButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                RegistrationPageGUI registrationPageGUI = new RegistrationPageGUI(client);
            }
        });
        loginButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                LoginPageGUI loginPageGUI = new LoginPageGUI(client);
            }
        });
    }

    public void setVisibility(boolean flag) {
        frame.setVisible(flag);
    }

    public Frame getFrame() {
        return frame;
    }
}
